import request from '../utils/request';
import constant from '../constant/constant'
import qs from 'qs';

/**
 * 提交验证申请
 */
export function qualificationExamination(payload) {
    let option = {
        method: 'POST',
        body: payload,
        headers: {
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/application/create', option)
}

/**
 * 查询当前技术供应方的所有技术
 */
export function getVerificationListByUserId(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/onvertechnology/list', option)
}

/**
 * 查询所选技术所到的验证阶段
 */
export function getverificationPhaseByTechnologyId(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/onvertechnology/phaseandexamination/id', option)
}

/**
 * 根据Id删除技术验证相关信息
 */
export function deleteVerificationByTechnologyId(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/applicant/results/delete', option)
}

/**
 * 查询当前技术申请所分配的验证机构
 */
export function getTechnologyVerificationMechanismByTechnologyId(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/mechanism/info/onvertechnology/id', option)
}

/**
 * 将流程推进到下一个阶段
 */
export function goToNextProcess(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/committee/qualification/phase/update', option)
}

/**
 * 查询当前技术的验证协议相关信息
 */
export function getVerificationAgreement(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/sign/protocol', option)
}

/**
 * 查询当前技术的测试数据相关信息
 */
export function getTestMechanismInformation(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/testMechanism/query/testdata', option)
}

/**
 * 查询当前技术的验证相关信息
 */
export function getVerificationMechanismInformation(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/verificationMechanism/query/days', option)
}

/**
 * 获取完成页面相关信息
 */
export function getFinishedInformation(payload) {
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/applicant/query/remainingValidDays', option)
}

/**
 * 重新验证
 */
export function restartProcess(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/verification/applicant/results/revalidate', option)
}

/**
 * 技术估值
 */
export function technologyValuation(payload){
    let option = {
        method: 'POST',
        body: qs.stringify(payload),
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        mode: "cors",
    }
    return request(constant.serverUrl + '/tvs/api/technology/valuation/verificationApplicationId', option)
}